package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqTransferBubbleSheetBySentNum;
import com.ruoyi.hqfinance.domain.HqTransferBubbleSheetPreAdjust;
import com.ruoyi.hqfinance.domain.vo.HqTransferBubbleSheetVo;
import com.ruoyi.hqfinance.mapper.HqTransferBubbleSheetBySentNumMapper;
import com.ruoyi.hqfinance.mapper.HqTransferBubbleSheetPreAdjustMapper;
import com.ruoyi.hqfinance.service.HqTransferBubbleSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HqTransferBubbleSheetServiceImpl implements HqTransferBubbleSheetService {
    @Autowired
    private HqTransferBubbleSheetPreAdjustMapper hqTransferBubbleSheetPreAdjustMapper;
    @Autowired
    private HqTransferBubbleSheetBySentNumMapper hqTransferBubbleSheetBySentNumMapper;
    @Override
    public List<HqTransferBubbleSheetPreAdjust> collectPreAdjust(HqTransferBubbleSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferBubbleSheetPreAdjust> preAdjustList = hqTransferBubbleSheetPreAdjustMapper.collectPreAdjust(vo);
        for (HqTransferBubbleSheetPreAdjust hqTransferBubbleSheetPreAdjust : preAdjustList){
            if (vo.getCollectTime() == 2){
                hqTransferBubbleSheetPreAdjust.setCollectDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return preAdjustList;
    }

    @Override
    public List<HqTransferBubbleSheetBySentNum> collectBySentNum(HqTransferBubbleSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqTransferBubbleSheetBySentNum> sheetBySentNums = hqTransferBubbleSheetBySentNumMapper.collectBySentNum(vo);
        for (HqTransferBubbleSheetBySentNum hqTransferBubbleSheetBySentNum : sheetBySentNums){
            if (vo.getCollectTime() == 2){
                hqTransferBubbleSheetBySentNum.setCollectDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return sheetBySentNums;
    }
}
